<div class="divMainContent" align="center">
<input type="hidden" id='hdtable' value="tbl_city"/>
<div id="divFormAdd">
[onshow;block=div;when [var.sCanEdit] = 1]

<form id="frFormAdd1" name="frFormAdd1">
<input type="hidden" id='hdlat' value="0"/>
<input type="hidden" id='hdlong' value="0"/>
<table class="tblInfo" id="tblFromAdd" width="100%">
<tr >
<td  style="width:30%">Loại Đơn vị hành chính</td>
<td ><select id='LocationType' onchange="setTable(this.value)">
<option value="1">Thành Phố/Tỉnh </option>
<option value="2">Quận/Huyện</option>
<option value="3">Phường/Xã </option>
</select></td>
</tr>
<tr id='trCity' >
<td  style="width:30%">Tên thành phố </td>
<td ><input type="text"  id="txtAddCity" /></td>
</tr>
<tr id='trProvince1' style="display:none">
<td  style="width:30%;"  >Thành Phố </td>
<td >[var.cmbCity1;htmlconv=no]</td>
</tr>
<tr id='trProvince2' style="display:none">
<td  style="width:30%">Tên Quận/Huyện </td>
<td ><input type="text"  id="txtAddProvince" /></td>
</tr>
<tr id='trWard1' style="display:none">
<td  style="width:30%;"  >Thành Phố/Tỉnh </td>
<td >[var.cmbCity2;htmlconv=no]</td>
</tr>
<tr id='trWard2' style="display:none">
<td  style="width:30%">Quận/Huyện </td>
<td id='tdProvince'>[var.cmbProvince;htmlconv=no]</td>
</tr>
<tr id='trWard3' style="display:none">
<td  style="width:30%">Tên Phường/Xã </td>
<td ><input type="text"  id="txtAddWard" /></td>
</tr>
<tr id='trmap' >

<td>Vị trí trên bản đồ </td>
<td></td>

</tr>
<!--<tr>
<td colspan="2" align="center">     <div id="maptracking2" style="height:350px;width:80%">

      </div></td> 
</tr>-->

<tr>
<td colspan="2" align="center">  
   <script>
    $(function() {
        $( "#tabs" ).tabs({
            ajaxOptions {
                error function( xhr, status, index, anchor ) {
                    $( anchor.hash ).html(
                        "Couldn't load this tab. We'll try to fix this as soon as possible. " +
                        "If this wouldn't be a demo." );
                }
            }
        });
    });
    </script>
<div class="demo">

<div id="tabs">
    <ul>
        <li><a href="#tabs-1">Preloaded</a></li>
        <li><a href="ajax/content1.html">Tab 1</a></li>
        <li><a href="../modules/main_users.php">Tab 2</a></li>
        <li><a href="alert('abc')">Tab 3 (slow)</a></li>
        <li><a href="ajax/content4-broken.php">Tab 4 (broken)</a></li>
    </ul>
    <div id="tabs-1">
           <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p>
    </div>
</div>

</div><!-- End demo --></td> 
</tr>
</table>
</form>
</div>

<div class="divGrid" id="divGrid">

</div>

</div>

<!--<script src='http//maps.google.com/maps?file=api&amp;v=2&amp;key=[var.gkey;]' type='text/javascript'></script>-->
<script language="javascript">

var _global;
 $(document).ready(function(){
//    _global=new Global();
//    _global.gMap=new GoogleFuncs();
//    _global.myMap=_global.gMap;
//    _global.checkMap=0;// 1VBD truoc,0 google map
//    $('#hdDrawMarker').val(1);    
//     _global.gMap.InitMap('maptracking2'); 
      initTable();       
 });
 
 function initTable(){
     
     $("#tableOne").tablesorter({ debug false, sortList [[0, 0]], widgets ['zebra', 'columnHighlight'] })
                .tablesorterPager({ container $("#pagerOne"), position:fixed false });
     
 }
     
 function setTable(value){
     
       $('#trbutton').css('display','');
     if(value==1){
         $('#hdtable').val('tbl_city');
         $('#trCity').css('display','');
         $('#trProvince1').css('display','none');
         $('#trProvince2').css('display','none');
         $('#trWard1').css('display','none');
         $('#trWard2').css('display','none');
         $('#trWard3').css('display','none');
         xajax_ajxLoadDataCity();
     }else if(value==2){
         $('#hdtable').val('tbl_province');
         $('#trCity').css('display','none');
         $('#trProvince1').css('display','');
         $('#trProvince2').css('display','');
         $('#trWard1').css('display','none');
         $('#trWard2').css('display','none');
         $('#trWard3').css('display','none');
         var param = new Array();
         if($('#cmbCity1').val()!=-1){
            param['city_id'] = $('#cmbCity1').val();  
         }
         xajax_ajxLoadDataProvince(param);  
     }else if(value==3){
         $('#hdtable').val('tbl_ward');
         $('#trCity').css('display','none');
         $('#trProvince1').css('display','none');
         $('#trProvince2').css('display','none');
         $('#trWard1').css('display','');
         $('#trWard2').css('display','');
         $('#trWard3').css('display','');
                  xajax_ajxLoadDataWard();  
         
     }else{
         $('#trbutton').css('display','none');
         $('#trCity').css('display','none');
         $('#trProvince1').css('display','none');
         $('#trProvince2').css('display','none');
         $('#trWard1').css('display','none');
         $('#trWard2').css('display','none');
         $('#trWard3').css('display','none');
         xajax_ajxLoadDataCity();
     }
 }

function SaveFormAdd(oform){
    var params = new Array();
    var elem = oform.elements;
    var flength = elem.length;    
    for(i=0;i<flength;i++){    
        if(elem[i].type !='button'&&elem[i].type !='reset'){
            params[elem[i].id]=elem[i].value;
        }
    }
    params['hdSaveStatus']=$('#hdSaveStatus').val();
    params['hdSaveId']=$('#hdSaveId').val();
    params['hdtable']=$('#hdtable').val();
    xajax_SaveFormAdd(params);    
}
function DeleteData(){
        var arID = new Array();
        var i = 0;
        $('INPUT[name=chkDelete]').each(function(){
            if($(this).attr('checked'))
            {
                arID[i] = $(this).attr('id');
                i++;
            }
        });
        var table = $('#hdtable').val();
        xajax_DeleteData(arID,table);        
}
function deletea(id){
     tmpObj = document.getElementById(id);
    tmpObj.style.display = "none";
}

$('#cmbCity2').change(function() {
      var param = new Array();
      xajax_ajxLoadProvince($('#cmbCity2').val());
      param['city_id']=$(this).val();
      xajax_ajxLoadDataWard(param);
});

$('#cmbCity1').change(function() {
    var param = new Array();
    param['city_id']=$(this).val();
    xajax_ajxLoadDataProvince(param);
          
});
function loadWard(id){
    var param = new Array();
    param['province_id']=id;
    xajax_ajxLoadDataWard(param); 
}


//xajax_ajxLoadDataCity();
var cal1 = CreateCalObject('txtFromDate', 'imgCal1');
var cal2 = CreateCalObject('txtToDate', 'imgCal2');
</script>
